﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Configuration;
using System.Data.SqlClient;

/// <summary>
/// Summary description for parentCPV
/// </summary>
namespace Bestlife.ERP.DataAccess
{
    public class parentCPV : System.Web.UI.Page
    {
        String updusersID;
        Double updbv;
        Double updTotalCommitions;
        String Get_parentID;
        Double getusercpv;
        Double store_cpv;
        String parentstaus;
        SqlDataReader rdRptatus;
        SqlDataReader rdR;
        SqlDataReader rdRccpv;
        Double parent_ppv;
        

        public parentCPV()
        {
            //
            // TODO: Add constructor logic here
            //
        }

        #region Calculate parent month_CPV

        public Double calculate_Parentmont_CPV(String id)
        {

            try
            {//try

                String connStr = ConfigurationManager.ConnectionStrings["MainConnStr"].ConnectionString;
                Bestlife.ERP.DataAccess.clsCon.connect(connStr);


                String sqlCpv = "SELECT CPV_month from Bonus where User_id='" + id + "'";

                rdRccpv = clsCon.ReadTable(sqlCpv);


                if (rdRccpv.Read())
                {
                    getusercpv = Double.Parse(rdRccpv["CPV_month"].ToString());

                }




            }//try


            catch (Exception err)
            {

                Response.Redirect("404.aspx?Massage=" + err.Message.ToString() + "Error+ Select cpv from bonus");
            }

            finally
            {
                clsCon.conn_new.Close();
                rdRccpv.Close();

            }
            //finally
            return getusercpv;
        }

        #endregion

        #region Calculate parent CPV

        public Double calculate_ParentCPV(String id)
        {

            try
            {//try



                String connStr = ConfigurationManager.ConnectionStrings["MainConnStr"].ConnectionString;
                Bestlife.ERP.DataAccess.clsCon.connect(connStr);


                String sqlCpv = "SELECT Cpv from Bonus where User_id='" + id + "'";

                rdRccpv = clsCon.ReadTable(sqlCpv);


                while (rdRccpv.Read())
                {
                    getusercpv = Double.Parse(rdRccpv["Cpv"].ToString());

                }




            }//try


            catch (Exception err)
            {

                Response.Redirect("404.aspx?Massage=" + err.Message.ToString() + "Error+ Select cpv from bonus");
            }

            finally
            {
                clsCon.conn_new.Close();
                rdRccpv.Close();

            }
            //finally
            return getusercpv;
        }

        #endregion


        #region Calculate parent bv

        public Double calculate_Parentbv(String id)
        {

            try
            {//try



                String connStr = ConfigurationManager.ConnectionStrings["MainConnStr"].ConnectionString;
                Bestlife.ERP.DataAccess.clsCon.connect(connStr);


                String sqlCpv = "SELECT Bv from Bonus where User_id='" + id + "'";

                rdRccpv = clsCon.ReadTable(sqlCpv);


                while (rdRccpv.Read())
                {
                    getusercpv = Double.Parse(rdRccpv["Bv"].ToString());

                }




            }//try


            catch (Exception err)
            {

                Response.Redirect("404.aspx?Massage=" + err.Message.ToString() + "Error+ Select cpv from bonus");
            }

            finally
            {
                clsCon.conn_new.Close();
                rdRccpv.Close();

            }
            //finally
            return getusercpv;
        }

        #endregion


        #region Calculate Parentppv

        public Double calculate_Parentppv(String id)
        {

            try
            {//try



                String connStr = ConfigurationManager.ConnectionStrings["MainConnStr"].ConnectionString;
                Bestlife.ERP.DataAccess.clsCon.connect(connStr);


                String sqlCpv = "SELECT ppv from Bonus where User_id='" + id + "'";

                rdRccpv = clsCon.ReadTable(sqlCpv);


                while (rdRccpv.Read())
                {
                    parent_ppv = Double.Parse(rdRccpv["ppv"].ToString());

                }




            }//try


            catch (Exception err)
            {

                Response.Redirect("404.aspx?Massage=" + err.Message.ToString() + "Error+ Select cpv from bonus");
            }

            finally
            {
                clsCon.conn_new.Close();
                rdRccpv.Close();

            }
            //finally
            return parent_ppv;
        }

        #endregion


        #region Calculate parent bv

        public Double calculate_Parentotal_bv(String id)
        {

            try
            {//try



                String connStr = ConfigurationManager.ConnectionStrings["MainConnStr"].ConnectionString;
                Bestlife.ERP.DataAccess.clsCon.connect(connStr);


                String sqlCpv = "SELECT Tbv FROM Bonus where User_id='" + id + "'";

                rdRccpv = clsCon.ReadTable(sqlCpv);


                while (rdRccpv.Read())
                {
                    getusercpv = Double.Parse(rdRccpv["Tbv"].ToString());

                }




            }//try


            catch (Exception err)
            {

                Response.Redirect("404.aspx?Massage=" + err.Message.ToString() + "Error+ Select cpv from bonus");
            }

            finally
            {
                clsCon.conn_new.Close();
                rdRccpv.Close();

            }
            //finally
            return getusercpv;
        }

        #endregion
        



    }
}